<template>
    <div class="container">
        <div class="row">

     


            <div class="col-md-8 col-md-offset-2" >


                <li class="list-group-item" style="border: 0px">


          <el-row>
                <el-col :span="4">
                    <div class="grid-content bg-purple">

                          <label style="height:40px;line-height:40px;">标题</label>
           
                    </div>
                    
                </el-col>

                <el-col :span="20">
                    <div class="grid-content bg-purple">
           
                        <el-input v-model="title" placeholder="请输入内容"></el-input>
                    </div>
                    
                </el-col>
        </el-row>

<br><br>
<script type="text/plain" id="editor" name="content" style="width:100%;height:300px;">
              
          </script>


          <br>
          
          <button class="btn btn-block" @click="getContent()">提交</button>
                </li>


            </div>
            

        
        </div>
    </div>
</template>

<script>

import conf from '../layout/conf.vue';//引用模块进来
    export default {
        mounted() {

     var ue = UE.getEditor('editor');  


        },
        data(){
            return {
                title:"",
                context:"",
                posturl:conf.url+"/index/post/create/",

            }
        },
        beforeCreate(){

        // var ue = UE.getEditor('editor');  
         console.log("加载咯!");

        },
        methods:{
             getContent() {

                 var self=this;
       
       let info=UE.getEditor('editor').getContent();
    
         var params = new URLSearchParams();
                params.append('title', this.title);
                params.append('content', info);
                var access_token=this.GetCookie("wlphp.cn");
                params.append('token', access_token);
                    

                    this.axios.post(this.posturl,params).then(response=>{
                        console.log(response);
                                            if(response['data']['status']=="error"){
                                                    this.$layer.msg("先登陆!!");
                                                    
                                                     setTimeout(function () {
                                                         self.$router.push('/admin')
                                                        },1000)
                                                    console.log("错误!");
                                                    console.log(response);
                                                    
                                                     

                                                }else{
                                                  this.$layer.msg("发布成功!");
                                                     setTimeout(function () {
                                                        self.$router.push('/')
                                                        },1000)
                                                            
                                                }
                                               
                     

                      })
            }



        }


    }
</script>


